import Rect3D from "../../standard/entities/Shape/Rect3D";
import Point3D from "../../standard/entities/Point/Point3D";
import BaseAnimationPainting from "../../standard/entities/Painting/BaseAnimationPainting";
import eUtils from '../../standard/utils/every-utils';

export default class Test3DPainting extends BaseAnimationPainting {

    constructor() {
        super();
        this.rect3d = new Rect3D(
            new Point3D(0, 0, 0), 100, 100, 100
        )
    }


    onPainterLoaded(painter) {
        super.onPainterLoaded(painter);
        painter.globalAlpha = 1;
        painter.fillStyle = 'rgba(255,0,0,1)';
        painter.strokeStyle = '#fff';
        let autoColor = eUtils['getRandomColor']();
        this.activeDrawnStep((painter, data) => {
            painter.drawInSession(() => {
                painter.drawShape3D(data.rect3d, (face, i) => {
                    if ('front' === face.name) {
                        painter.fillStyle = '#FFF';
                    } else {
                        painter.fillStyle = 'rgba(255,0,0,1)';
                    }
                    painter.fill();
                    painter.stroke();
                });
            })
        })
    }


    nextFrame(painter) {
        super.nextFrame(painter);
        this.rect3d.rotateX(1);
        this.rect3d.rotateY(1);
        this.rect3d.rotateZ(1);
    }

    exportDrawnData() {
        return {rect3d: this.rect3d}
    }
}